home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-07-12 | 4.2 KB | 81 lines | [TEXT/GEOL] |
- Item forwarded by BURBECK.S to LICHTY
-
- Item 8580162 9-July-89 19:32
-
- From: BURBECK.S Burbeck, Steve
-
- To: MACAPP.TECH$ MACAPP Tech
-
- Sub: Even more on GC
-
- Few programmers, even longtime users of systems with garbage collection (GC),
- give much thought to the issues underlying GC. So let me try to open an
- alternative facet to the debate about performance, reference counting,
- generation scavenging, assignment operator overloading and language dependence.
- Let's first consider the value of GC. If GC is of little value, performance
- doesn't matter. If we agree that GC is valuable, then we can debate about how
- much performance hit there might be.
-
- GC encompasses two separate issues: garbage detection and memory compaction.
- The Mac memory manager already does the second. But, except for Smalltalk and
- Lisp, the programmer must do the former: and to do so, (s)he must deeply
- understand the runtime dependencies between objects at the time the code is
- written. Even in relatively simple cases, errors are all too common: the
- programmer often causes objects to be freed too soon, causing relatively prompt
- crashes, or fails to free them at all, thereby producing memory leaks which run
- the program out of memory at some unspecified time. Memory leaks are a
- pernicious and often unrecognized problem. For instance, the developers of
- ET++ (a C++ environment for Sun machines based loosely on MacApp) did a study
- of memory leakage. They were horrified to find that as much as 70% of their
- memory was garbage! And note that they had the "benefit" of constructors and
- destructors. The problem may be even more acute with Object Pascal.
-
- But a more important, if subtle, problem is that the programmer's need to
- easily be able to know when an object can be freed forces a restrictive style
- of object references. Object references tend to be forced into simple tree
- structures with a few well defined roots (i.e., the document, the application,
- or a window). Otherwise, it becomes very difficult to know when an object can
- safely be freed. Imagine, for instance, that an object is referenced both by
- an instance variable (field) in some object and is also referenced by an entry
- in some collection object (e.g., a sorted list). Should the programmer free
- the object when the list goes away, or when the other referencing object goes
- away. In some specialized cases, the programmer knows which object will live
- longer. But more often, the programmer simply must avoid the problem by not
- placing references in both places. And more complex lattice structures of
- object references are completely out of the question without GC. Yet, since
- most programmers have little if any experience with systems that have GC, few
- of them recognize how useful a freer pattern of object references can be.
-
- So I would pose some questions: How much of your development time is spent
- tracking down object-freeing bugs? How many of you are sure you don't have
- memory leakage? How many times have you wanted to keep a reference to an
- object in multiple places but were disuaded by the fact that you couldn't know
- when to free it? How many of you wished you had the kind of collection classes
- available in Smalltalk?
-
-
- Steve Burbeck
-
-
-
-
- PS -- some specific comments on previous links:
-
- 1) I doubt that assignment is significantly more common in hybrid languages
- than in Smalltalk. Does anyone have any evidence to support such an assertion?
-
- 2) Geoff, what do you mean by a language "designed for GC"?
-
- 3) A nit: the problem is one of references to new objects being assigned to
- objects in "older" spaces. In that case, the object may be alive even though
- no other "new" space object points to it. A simple solution is to "promote"
- such objects out of the "new" space.
-
- 4) I don't understand your assertion that gc is not appropriate for hybrid
- languages. You might argue that the pattern of object creation and destruction
- on hybrid systems is inherently simple (perhaps because of compiler
- restrictions that make collections less useful), hence GC doesn't buy you much.
- But if so, why are there so many bugs due to incorrect freeing of objects?
-
-
-